//
//  PostReplyCell.m
//  sensen_ios
//
//  Created by mc on 16/3/25.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "PostReplyCell.h"
#import "ZKTextImgReplaceHandle.h"


@implementation PostReplyCell



+(instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString * cellIdentifier = @"PostReplyCell";
    PostReplyCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell ==nil) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
    
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self setupSubViews];
        
    }
    return self;
}
- (void)setupSubViews{
    
    UIImageView * imageView = [[UIImageView alloc] init];
    [self addSubview:imageView];
    imageView.image = [UIImage imageNamed:@"论坛_我的帖子_回复"];

    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(-5);
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10);
    }];
    
    imageView.image = [[UIImage imageNamed:@"论坛_我的帖子_回复"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 100, 20, 200)
                                                                             resizingMode:UIImageResizingModeStretch];

    self.lable = [[UILabel alloc] init];
    [self addSubview:_lable];
    [_lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(10);
        make.bottom.equalTo(self).offset(-10);
        make.left.equalTo(self).offset(16);
        make.right.equalTo(self).offset(-16);
    }];
    _lable.textColor = [UIColor darkGrayColor];
    _lable.font = FONT(16);
    _lable.numberOfLines = 0;

}


- (void)setPostModel:(PostModel *)postModel{
    _postModel = postModel;
    _lable.text = @"原帖：[森森鱼缸水族中大型超白鱼缸1.2/1.5/1.8/2米鱼缸底滤森森鱼缸水族中大型超白鱼缸1.2/1.5/1.8/2米鱼缸底滤森森鱼缸水族中大型超白鱼缸1.2/1.5/1.8/2米鱼缸底滤]";
    
}

- (void)setPostReplyModel:(PostReplyModel *)postReplyModel{
    _postReplyModel = postReplyModel;
    
    
    NSString * string =  [NSString stringWithFormat:@"回复帖子：%@", postReplyModel.post_message];
    NSMutableAttributedString *attr = [ZKTextImgReplaceHandle handleText:string withRegex:nil];
    if (attr) {
        _lable.attributedText = attr;
    } else {
        _lable.text = string;
    }

   
   
}



@end
